home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5778 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.5 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: How to tell if a file exists in C
  5. Date: Mon, 19 Feb 96 19:54:33 GMT
  6. Organization: none
  7. Message-ID: <824759673snz@genesis.demon.co.uk>
  8. References: <4eqkj6$ipo@charm.magnus.acs.ohio-state.edu> <4eqn9q$dr1@sparcserver.lrz-muenchen.de> <3121db3e.43150046@nntp.ix.netcom.com> <4ftpnk$i74@cafu.fl.net.au> <824493561snz@genesis.demon.co.uk> <4g8132$mg9@cafu.fl.net.au>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4g8132$mg9@cafu.fl.net.au> als@fl.net.au "Andrew Snow" writes:
  15.  
  16. >>access() is a specialised function under Unix/POSIX to test permissions
  17. >>against the real user/group ID's. If you don't want to do that specifically
  18. >>you should never use access() (and why on other systems you should avoid it
  19. >>where portability is concerned). stat() is the way to go in that case.
  20. >
  21. >Specialised?  well its a part of every single DOS compiler I've ever
  22. >seen.  
  23.  
  24. Why is it that so may DOS progarmmers seem to have this tunnel vision?
  25. Believe it or not there are systems besides DOS out there. My point remains
  26. that if you want to code for portability you avoid access() (as I noted you
  27. can use stat() instead in most cases). Where systems define an access()
  28. function it is typically based on the Unix/POSIX version (and that includes
  29. DOS). I quote from Lewine:
  30.  
  31. "access() uses the real UID, not the effective UID. It is not a general
  32. utility for finding out 'Can I do this?' before doing a call. It is used by
  33. SETUID programs to check their actions".
  34.  
  35. My point is that porting code that uses access() to different platforms may
  36. not give the expected results because you are not using it for the purpose
  37. for which it was intended. That's why it is best to use an alternative.
  38.  
  39. >>However neither of these are as portable as fopen() since that is defined by
  40. >>the C language.
  41. >
  42. >True, however I was only offering access() as a viable alternative.
  43.  
  44. So long as you understand its limitations.
  45.  
  46. >>>If you want to see if the file is readable as well as exists,
  47. >
  48. >>Can a file be readable yet not exist?
  49. >
  50. >No, but did you really want me to spell it out?  You ought to have
  51. >been able to figure it out. Sorry if you couldn't.
  52.  
  53. I was just wondering if you'd figured it out.
  54.  
  55. -- 
  56. -----------------------------------------
  57. Lawrence Kirby | fred@genesis.demon.co.uk
  58. Wilts, England | 70734.126@compuserve.com
  59. -----------------------------------------
  60.